package servlet;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;



//1. 监听创建和销毁
//ServletContextListener				监听ServletContext创建和销毁时
//ServletRequestListener				监听HttpSession创建和销毁时
//HttpSessionListener					监听ServletRequest创建和销毁时

//2. 监听作为域对象时 设置覆盖移除属性
//ServletContextAttributeListener		监听ServletContext设置修改移除属性时
//HttpSessionAttributeListener			监听HttpSession设置修改移除属性时
//ServletRequestAttributeListener		监听ServletRequest设置修改移除属性时


@WebListener
public class Listener1 implements ServletContextListener{
	
	@Override
	public void contextInitialized(ServletContextEvent sce) 
	{
		System.out.println("ServletContext 初始化時執行代碼");
	}
	
	
	@Override
	public void contextDestroyed(ServletContextEvent sce) 
	{
		System.out.println("ServletContext 销毁时执行代码");
	}
}
